/*
 * @Descripttion: 指令注册 
                  以文件名为指令名 
                  例如：v-testDeom 会自动注册为testDeom指令 
 * @Author: jhw
 * @Date: 2023-07-21 15:57:14
 * @LastEditors: jhw
 * @LastEditTime: 2023-12-13 14:40:22
 */
import { App } from 'vue';

const allDirectives = import.meta.glob('./**', { eager: true }) as Record<string, any>;

export default {
  install(app: App<Element>) {
    Object.keys(allDirectives).forEach((key) => {
      const reg = /[a-z]+/gi;
      const directiveName = key.match(reg)?.[0];
      app.directive(directiveName as string, allDirectives[key].default);
    });
  },
};
